package com.example.Annocation.compentScann;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.FilterType;
import com.example.Annocation.commons.Student;
/**
 * @Description TODO
 * @Date 2024/5/14 16:09
 * @Created by houjunfeng
 */
@Configuration



//将这个配置类里面没有的扫描进来
//@ComponentScan(value = "com.example.annocation.compentScann",excludeFilters = {
//        @ComponentScan.Filter(type = FilterType.ANNOTATION,classes = {Controller.class})
//})
@ComponentScan(value = "com.example.Annocation.compentScann",includeFilters = {
//        @ComponentScan.Filter(type = FilterType.ANNOTATION,classes = {Controller.class}),//按注解
//        @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE,classes = {BookService.class})//按给定类型
        @ComponentScan.Filter(type = FilterType.CUSTOM,classes = {MyTypeFilter.class})//按自定义类型
},useDefaultFilters = false)
//excludeFilters排除
//includeFilters包含
//useDefaultFilters是否开启默认扫描规则，默认是将全部扫描，需要与前两个Filters搭配使用
public class CompentScannConfiguration {
    //默认bean名字为方法名 如果bean写了名字就用这个名字
    @Bean(name = {"student01"})
    public Student getStudent(){
        System.out.println("开始创建student的bean");
        return new Student("李四",35,22);
    }
}
